package net.game;


import static net.game.ButtonGrid.EXCLUDE_BUTTON;
import static net.game.ButtonGrid.NORMAL_BUTTON;
import static net.game.ButtonGrid.START_IGNORE_LINE;
import static net.game.ButtonGrid.START_NORMAL_LINE;
import net.chemistry.AtomID;
import net.util.GraphicsUtil;

import org.lwjgl.opengl.Display;
import org.lwjgl.util.Rectangle;
import org.newdawn.slick.opengl.Texture;

public class MoleculeBuilderGUI extends AbstractGUIComponent
{
	public static final Texture TABLE_IMG = GraphicsUtil.loadTexture("table.png");
	
	private ButtonGrid periodicTable = new ButtonGrid(0,0, 18, 10, 32, 48, new int[][]
			{
				{
					NORMAL_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,
					EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,
					EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,NORMAL_BUTTON
				},
				{
					NORMAL_BUTTON,NORMAL_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,
					EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,
					EXCLUDE_BUTTON,START_NORMAL_LINE
				},
				{
					NORMAL_BUTTON,NORMAL_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,
					EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,
					EXCLUDE_BUTTON,START_NORMAL_LINE
				},
				{START_NORMAL_LINE},
				{START_NORMAL_LINE},
				{START_IGNORE_LINE},
				{START_IGNORE_LINE},
				{START_IGNORE_LINE},
				{EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,START_IGNORE_LINE},
				{EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,EXCLUDE_BUTTON,START_IGNORE_LINE}
			});
	
	public MoleculeBuilderGUI()
	{
		bounds = new Rectangle(0,32,128, Display.getHeight() - 32);
		
		
		int i = 0;
		
		for(Button b : periodicTable.getButtons(NORMAL_BUTTON))
		{
			if (i >= AtomID.values().length)
			{
				break;
			}
			
			b.setText(AtomID.values()[i].abbrev);
			i++;
		}
	}
	
	public void render()
	{		
		super.render();
		
		if (mousein)
		{
			//GL11.glColor4f(1, 1, 1, 1);
			
			periodicTable.render();
			
			//GraphicsUtil.renderImage(TABLE_IMG, bounds.getX(), bounds.getY());
			//GL11.glDisable(GL11.GL_TEXTURE_2D);
		}
	}
}
